package servlet;

import java.io.IOException;
import java.sql.SQLException;
import java.util.ArrayList;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import bean.Alarm;
import bean.Detection;
import bean.Online;
import deo.baojingdeo;
import deo.jiancedeo;
import deo.onlinedeo;

@SuppressWarnings("serial")
public class AlarmServlet extends HttpServlet{
	public void doGet(HttpServletRequest request, HttpServletResponse response)  
            throws ServletException, IOException {  
        this.doPost(request, response);  
    }  
    public void doPost(HttpServletRequest request, HttpServletResponse response)  
            throws ServletException, IOException {
    	
    	baojingdeo db = new baojingdeo();  
    	String sql = "select outlet.outlet_name,company.company_name,count(alarm.oreport_value),alarm.oreport_date,count(alarm.freport_value),alarm.freport_date from alarm  inner join outlet on alarm.outlet_id=outlet.outlet_id inner join company on outlet.company_id=company.company_id GROUP BY outlet.outlet_id";
        
//    	String sql = "select b.outlet_name,c.company_name,count(a.oreport_value),a.oreport_date,count(a.freport_value),a.freport_date"
//        		+ "from alarm a inner join outlet b on a.outlet_id=b.outlet_id "
//        		+ "inner join company c on b.company_id=c.company_id ";
//        
        ArrayList<Alarm> list = null;
		try {
			list = db.getAlarmList(sql);
		} catch (SQLException e) {
			e.printStackTrace();
		}
        request.setAttribute("list", list);  
        request.getRequestDispatcher("baojing.jsp").forward(request, response);  
    }  
}
